<?php
session_start();

include_once "src/controller/regmanagement/AccountManager.php";
include_once "src/model/Consultant.php";
include_once "src/model/ProvidedService.php";
//sleep(3);
try {
    $user = new Consultant();

    $consultantId = $_POST["consultantId"];
    $newFirstName = $_POST["firstName"];
    $newLastName = $_POST["lastName"];
    $oldEmail = $_SESSION["email"];
    $newEmail = $_POST["email"];
    $oldPassword = $_POST["oldPassword"];
    $newPassword = $_POST["newPassword"];
    $changePasswordIndicator = $_POST["changePasswordIndicator"];

    if (AccountManager::updateUserAccount($consultantId, $oldEmail, $newEmail,
                                          $newFirstName, $newLastName, $newPassword,
                                          $oldPassword, $changePasswordIndicator)) {
        $_SESSION["email"] = $newEmail;
        $_SESSION["userFullName"] = $newFirstName . " " . $newLastName;
        echo "1";
    } else {
        echo "0";
    }
} catch (Exception $e) {
    echo $e->getMessage();
}
?>
